﻿CREATE TABLE DBBackOffice.DBOrder (
	ID								uniqueidentifier PRIMARY KEY,							/* Unique GUID for this order */
	DBBackOfficeID					uniqueidentifier NOT NULL,								/* is inside this back office */
	DBExecutionContextINodeID		uniqueidentifier NOT NULL,								/* book under ExecutionContextINode with this ID*/
	DBInstrumentStaticDataID		uniqueidentifier NOT NULL,								/* On instrument with this ID */
	Quantity						integer NOT NULL CHECK (Quantity>0),					/* Quantity to buy/sell */
	Price							float NOT NULL CHECK (Price>0),							/* At this price */
	Way								varchar(4) NOT NULL,									/* 'Buy' ot 'Sell' */
	Type							varchar(16) NOT NULL,									/* 'Limit' of 'FillOrKill' etc ... */
	TimeStamp 						datetime2 NOT NULL,										/* Creation date */

	FOREIGN KEY (DBBackOfficeID) REFERENCES DBBackOffice.DBBackOffice(ID) ON DELETE CASCADE,
);